<!--
/**************************************************
* @(#)organizationview.jsp
*
* Copyright (c) 2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/2/14, owen xia
*  1) first release
   2) add javascript method changelist2,implemnt select jump
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8"%>

<%@ include file="../common.jsp"%>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>

<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>
<%@ taglib uri="../WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="../WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="../WEB-INF/struts-logic.tld" prefix="logic"%>

<html>
<head>
<title>订货单位常用联系方式</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK rel="stylesheet" href="<%=root%>/css/caigouxitong.css">
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
</head>

<%
String tReQuery = (String)request.getAttribute("requery");
%>
<script language="JavaScript">
function process(val){
      
     
      if(val == 'Q' || val == 'Qre')
      {
				  if (false)
				  {
					<%
					    if(tReQuery!=null && tReQuery.equals("true")){
					%>
					     checkform.action='<%= response.encodeURL(request.getContextPath() + "/A400802.do") %>';
                         checkform.submit();
                        return true;
			    	<%}%>
		    	  }
		    	  else if (val == 'Q')
		    	  {
						 checkform.action='<%= response.encodeURL(request.getContextPath() + "/A400802.do") %>';
                         checkform.submit();
                        return true;
		    	 }
    	
		}
 }

function add_(value){
	 var gs_deliver_goods_addr = value[0];
	 var gs_order_contact_name = value[1];
	 var gs_order_contact_phone = value[2];
	 var manuftype1 = value[3];
	 var manuftype2 = value[4];
	 for(i=0;i<gs_deliver_goods_addr.length;i++){
	 	document.getElementById("gs_deliver_goods_addr"+i).value = gs_deliver_goods_addr[i];
	 	document.getElementById("gs_order_contact_name"+i).value = gs_order_contact_name[i];
	 	document.getElementById("gs_order_contact_phone"+i).value = gs_order_contact_phone[i];
	 	//alert(gs_deliver_goods_addr[i]+","+gs_order_contact_name[i]+","+gs_order_contact_phone[i]);
	 }
	 document.getElementById("manuftype1").value = manuftype1;
	 document.getElementById("gs_org_id").value = manuftype2;
}

function add(){
   //checkform.action='<%=root%>/A400803.do';
   //checkform.submit();
		var result = new Array();
		result = showModalDialog("<%= response.encodeURL(request.getContextPath() + "/A400803.do") %>", window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:600px;help:no;");
        if(result != null){
			add_(result);
			
			//查询条件
			document.pager.s_org_id.value = document.getElementById("org_id").value;
			document.pager.s_gsdelivergoodsaddr.value = document.getElementById("gsdelivergoodsaddr").value;

			document.pager.action = "<%=response.encodeURL(root+"/A400804.do")%>";	
			document.pager.submit();
		    //alert("联系方式添加成功！");
			//process('Q');
			//window.location.href = window.location.href;
			//window.location.reload();
		 }

   //window.open("<%=root%>/A400803.do");
   //return true;
}

function mod_(value){
		document.getElementById("goods_addr_id").value = value[0];
		document.getElementById("gs_org_id").value = value[1];
		document.getElementById("goods_addr").value = value[2];
		document.getElementById("contact_name").value = value[3];
		document.getElementById("contact_phone").value = value[4];
	
}


function mod(x,y){
      pager.gs_org_id.value=x;
      //alert(x);
      pager.gs_deliver_goods_addr_id.value=y;
      //alert(y);
      var orgid;
      var addrid;
      orgid=pager.gs_org_id.value;
      addrid=pager.gs_deliver_goods_addr_id.value;
      //var result = null;	
	  //window.open("<%=root%>/A400805.do?orgid="+orgid+"&addrid="+addrid);
	  var result = null;	
		result = showModalDialog("<%= response.encodeURL(request.getContextPath() + "/A400805.do") %>?orgid="+orgid+"&addrid="+addrid, window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:600px;help:no;");
        if(result != null)
        {
			mod_(result);
			document.pager.action = "<%=response.encodeURL(root+"/A400806.do")%>";	

			//查询条件
			document.pager.s_org_id.value = document.getElementById("org_id").value;
			document.pager.s_gsdelivergoodsaddr.value = document.getElementById("gsdelivergoodsaddr").value;
						
			document.pager.submit();
		}
    }  

function clean(){
      checkform.org_id.value ="";
	  checkform.gsdelivergoodsaddr.value="";		
	  
    }
    
function del(x,y){
  if (confirm("是否删除此订货单位常用联系方式？")) {
   pager.gs_org_id.value=x;
   //alert(x);
   pager.gs_deliver_goods_addr_id.value=y;
   //alert(y);
   delform.gs_deliver_goods_addr_id.value=pager.gs_deliver_goods_addr_id.value;
   delform.gs_org_id.value=pager.gs_org_id.value;
   delform.org_id.value=checkform.org_id.value;
   delform.action='<%= response.encodeURL(request.getContextPath() + "/A400807.do") %>';
   
   //查询条件
   document.delform.s_org_id.value = document.getElementById("org_id").value;
   document.delform.s_gsdelivergoodsaddr.value = document.getElementById("gsdelivergoodsaddr").value;
			
   delform.submit();
   //window.location.reload();
   return true;
   }
}
</script>

<%
	ResultProcess tOrgList = (ResultProcess)request.getAttribute("OrderDeptInfoList");
	ArrayList tList = new ArrayList();
%>
<body  BGCOLOR=#f2f2f2 LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 onload="<%if(tReQuery!=null && tReQuery.equals("true")){out.print("process('Q')");}%>">
<p><br></p>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">订货单位常用联系方式</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>

<br>

<!-- form start -->
<form name="checkform" method="get" onsubmit="if(!process()) return false;">

<!--修改记录时保存翻页信息-->
<%
if(tReQuery!=null && tReQuery.equals("true"))
{
	String s_pageNo = (String)request.getAttribute("s_pageNo");
	if (s_pageNo == null || s_pageNo.equalsIgnoreCase(""))
		s_pageNo = "1";
	
%>
	<input type='hidden' name='pageNo' value='<%=s_pageNo%>'>
<%
}
%>



<font id="err_font" name="err_font" color="#000000"><input type="hidden" name="hidden" value=""></font>
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr> 
  <td valign="top" class="title">
 	
	  <table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
		<tr> 
		  <td class="bg_column"><font id="bank_id_font" color="#000000">订货单位编号&nbsp;</FONT></td>
		  <td align=left class="bg_row_odd">
		    <select name="org_id">	
						<option value="">---全部---</option>				
						<%
						    ArrayList tAllOraganization = (ArrayList)request.getAttribute("AllOraganization");
							String torgid = request.getParameter("org_id");
							if (torgid == null) torgid = (String)request.getAttribute("s_org_id");
							if (torgid == null) torgid = "";
							
							if(tAllOraganization != null && tAllOraganization.size() > 0 ){
								for(int i=0; i<tAllOraganization.size(); i++){
								    GSOrganizationBean tGSOrganizationBean = (GSOrganizationBean)tAllOraganization.get(i);
								    if(torgid != null && torgid.equals(tGSOrganizationBean.getGs_org_id())){
						%>
								<option value="<%=tGSOrganizationBean.getGs_org_id()%>" selected><%=tGSOrganizationBean.getGs_org_name()%></option>
						<%			        
								    }else{
						%>
								<option value="<%=tGSOrganizationBean.getGs_org_id()%>"><%=tGSOrganizationBean.getGs_org_name()%></option>
								
						<%			}	
								}
							}
						%>

			</select>
		  </td>
		  <td class="bg_column" align=center><font id="mer_id_font" color="#000000">送货地址&nbsp;</font></td>
		  <td align=left class="bg_row_odd">
		  	 <%
		  	 String gsdelivergoodsaddr = request.getParameter("gsdelivergoodsaddr");
		  	 if (gsdelivergoodsaddr == null) gsdelivergoodsaddr = (String)request.getAttribute("s_gsdelivergoodsaddr");
		  	 if (gsdelivergoodsaddr == null) gsdelivergoodsaddr = "";
		  	 %>
             <input type="text" name="gsdelivergoodsaddr" value="<%=gsdelivergoodsaddr%>" maxLength=24 size="24"></input>
		  </td>
		  
		</tr>
		
	  </table>
	</td>
  </tr>
</table>
<%
if(tOrgList != null){
                    int totalRecords = 0;
                    int defaultPageSize = 10;
                    totalRecords = tOrgList.getRecordsSize();
              %>            
                <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
                <%tList = tOrgList.getDisplayRecords(index.intValue(),pageSize.intValue()); %>
                </page:pager>
                <%} %>
</form>
<p align="center">  
		<input type="button" class="kuang" value="查询" onclick="process('Q')"/>&nbsp;
        <input type="button" class="kuang" value="清空" onclick="clean()"/>&nbsp;				
	
    </p>
<!-- form end -->
<center>
<!--
****************************显示列表*********************************************
-->

<%
	
	if(tOrgList != null){
%>
 <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
            <td> 
               
                <form name='pager' method="post">
			    <input type=hidden name="gs_deliver_goods_addr_id" >
                
                <!--增加/修改时查询条件-->
				<input type="hidden" name="s_org_id" value="">
				<input type="hidden" name="s_gsdelivergoodsaddr" value="">
                
                <!--翻页时查询条件-->
				<input type="hidden" name="org_id" value="<%=torgid%>">
				<input type="hidden" name="gsdelivergoodsaddr" value="<%=gsdelivergoodsaddr%>">
				
				<!---->
                
                <!--以下for增加-->
                <%for(int i=0;i<30;i++){%>
                	<input type='hidden' id= "gs_deliver_goods_addr<%=i%>" name="gs_deliver_goods_addr" >
                	<input type='hidden' id= "gs_order_contact_name<%=i%>" name="gs_order_contact_name" >
                	<input type='hidden' id= "gs_order_contact_phone<%=i%>" name="gs_order_contact_phone" >
                <%}%>
                <input type='hidden' name="manuftype1">
                <input type='hidden' name="gs_org_id">
                <!--以下for修改-->
                <input type="hidden" name="goods_addr_id">
                <input type="hidden" name="goods_addr">
                <input type="hidden" name="contact_name">
                <input type="hidden" name="contact_phone">
			
                <table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=98% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20> 
                        <td class=top align=middle width="5%"> 
                            
                        </td>
                        <td class=top align=middle width="5%"> 
                          
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">订货单位编号</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">送货地址</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">订货联系人姓名</div>
                        </td>
                        <td class=top align=middle> 
                           <div align="center" class="txt_content">订货联系电话</div>
                        </td>
                      
						 
                    </tr>
                   <%
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
							String[] tStr = (String[])tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}
					%>
                    <tr <%=tTempStr%> height=20>
                         <td class=top align=middle> 
                            <div align="center" class="txt_content">
                           
                            <input type="button" class="kuang" value="修改" onclick="mod('<%=tStr[0]%>','<%=tStr[4]%>')"/>
                            
                            </div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">
                            <input type="button" class="kuang" value="删除" onclick="del('<%=tStr[0]%>','<%=tStr[4]%>')"/>
                            </div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">
                            <%=tStr[5]%>
                            </div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">
                            <%=tStr[1]%>
                            </div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">
                            <%=tStr[2]%>
                            </div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content">
                            <%=tStr[3]%>
                            </div>
                        </td>
                        
						
                    </tr>
                  			
					<%	
							}
					%>
                     <tr class="bg_column" height=20>
					    <td width="960" height="16" colspan="12" align="right">
								<!--导航条-->
								<page:navigator type='text' queryForm="checkform"/>
					    </td>
					  </tr>	
					  <%
						}else{
					%>
							<font color="red">没有符合条件的订货单位常用联系方式</font>
					<%
						}
					%>
                    </tbody> 
                </table>
               </form>
            </td>
        </tr>
    </table>
 
 
   <!--
****************************显示列表*********************************************
   -->
   
</center>
<form action="" name="delform" method="post">	
      <input type=hidden name=gs_org_id>		
      <input type=hidden name=gs_deliver_goods_addr_id>		
      <input type=hidden name=org_id>		

	  <input type="hidden" name="s_org_id" value ="">
	  <input type="hidden" name="s_gsdelivergoodsaddr" value ="">
	  
	  <input type="hidden" name="s_pageNo" value ="">
</form>
<p align="center">  
		<input type="button" class="kuang" value="增加" onclick="add()"/>&nbsp;
    </p>
<%} 
	if(tOrgList == null && request.getAttribute("requery") != null && request.getAttribute("requery").equals("true")){
%>
		<p align='left'><font size="2">数据查询中......</font></p>

<%
	}
%>                           
</body>
</html>
